<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

    <head>
        <title>解冻申请管理</title>
         <%-- 全站样式 --%>
        <jsp:include page="/WEB-INF/jsps/template_style.jsp"></jsp:include>
    
    </head>

    <body class="page-body skin-navy">
        <div class="page-container">
			<%--侧边栏 --%>
			<jsp:include page="/WEB-INF/jsps/sidebar.jsp"></jsp:include>
            <div class="main-content">
               <%--导航栏 --%>
				<jsp:include page="/WEB-INF/jsps/navbar.jsp"></jsp:include>
                <div class="page-title">
                    <div class="title-env">
                        <h1 class="title">解冻申请审核</h1>
                        <p class="description">
                            您可以在此页面上处理用户的所有解冻申请请求。
                        </p>
                    </div>
                </div>
                <div class="row">
                    <!-- Tabbed panel 2 -->
                    <div class="panel panel-default panel-tabs">
                        <!-- Add class "collapsed" to minimize the panel -->
                        <div class="panel-heading">
                            <h3 class="panel-title">解冻申请</h3>
                            <div class="panel-options">
                                <ul class="nav nav-tabs">
                                    <li class="active">
                                        <a href="#tab-4" data-toggle="tab">待审核</a>
                                    </li>
                                    <li>
                                        <a href="#tab-5" data-toggle="tab">通过</a>
                                    </li>
                                    <li>
                                        <a href="#tab-6" data-toggle="tab">拒绝</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab-4">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <!-- 待审核面板 -->
                                            <table class="table table-bordered table-striped" id="example-2">
                                                <thead>
                                                    <tr>
                                                    	<th>申请编号</th>
                                                        <th>邮箱</th>
                                                        <th>申请解冻理由</th>
                                                        <th>申请时间</th>
                                                        <th>申请人</th>
                                                        <th>操作</th>
                                                        
                                                    </tr>
                                                </thead>
                                                <tbody class="middle-align">
                                                <c:forEach items="${audit}" var="user">
                                                    <tr>
                                                    	<td>${user['applicationID'] }</td>
                                                        <td>${user['email'] }</td>
                                                        <td>${user['applicationContent']}</td>
                                                        <td>${user['applicationTime']}</td>
                                                        <td>${user['name']}</td>
                                                        <td>
                                                            <a href="#" class="btn btn-secondary btn-sm btn-icon icon-left getID" data-toggle="modal" data-target="#check">
                                                                通过
                                                            </a>

                                                            <a href="#" class="btn btn-danger btn-sm btn-icon icon-left getID" data-toggle="modal" data-target="#refuse">
                                                                拒绝
                                                            </a>

                                                        </td>
                                                    </tr>
                                                     </c:forEach>
                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="tab-5">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <!--- 通过面板 -->
                                            <table class="table table-bordered table-striped" id="example-2">
                                                <thead>
                                                    <tr>
                                                    	<th>申请编号</th>
                                                        <th>邮箱</th>
                                                        <th>申请解冻理由</th>
                                                        <th>申请时间</th>
                                                        <th>申请人</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody class="middle-align">
                                                   <c:forEach items="${pass}" var="user">
                                                    <tr>
                                                    	<td>${user['applicationID'] }</td>
                                                        <td>${user['email'] }</td>
                                                        <td>${user['applicationContent']}</td>
                                                        <td>${user['applicationTime']}</td>
                                                        <td>${user['name']}</td>
                                                        <td>
                                                            <a href="#"  class="btn btn-info btn-sm btn-icon icon-left show" data-toggle="modal" data-target="#read">
                                                                查看
                                                            </a>

                                                        </td>
                                                    </tr>
                                                     </c:forEach>
                                                   
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                            
                                </div>
                                <div class="tab-pane" id="tab-6">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <table class="table table-bordered table-striped" id="example-2">
                                                <thead>
                                                <tr>
                                                	<th>申请编号</th>
                                                    <th>邮箱</th>
                                                    <th>申请解冻理由</th>
                                                    <th>申请时间</th>
                                                     <th>申请人</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody class="middle-align">
                                                 <c:forEach items="${refuse}" var="user">
                                                    <tr>
                                                   		 <td>${user['applicationID'] }</td>
                                                        <td>${user['email'] }</td>
                                                        <td>${user['applicationContent']}</td>
                                                        <td>${user['applicationTime']}</td>
                                                        <td>${user['name']}</td>
                                                        <td>
                                                        <a href="#" class="btn btn-danger btn-sm btn-icon icon-left show" data-toggle="modal" data-target="#read">
                                                            查看
                                                        </a>

                                                        </td>
                                                    </tr>
                                                     </c:forEach>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="tab-7">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                        <!---------所有申请面板-------------------------------------------------------------------------->
                                            <table class="table table-bordered table-striped" id="example-2">
                                                <thead>
                                                <tr>
                                                	<th>申请编号</th>
                                                    <th>邮箱</th>
                                                    <th>申请解冻理由</th>
                                                    <th>申请时间</th>
                                                    <th>申请人</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody class="middle-align">
                                                  <c:forEach items="${all}" var="user">
                                                <tr>
                                                	<td>${user['applicationID'] }</td>
                                                    <td>${user['email'] }</td>
                                                    <td>${user['applicationContent']}</td>
                                                    <td>${user['applicationTime']}</td>
                                                    <td>${user['name']}</td>
                                                   
                                                    <td>
                                                        <a href="#" class="btn btn-info btn-sm btn-icon icon-left" data-toggle="modal" data-target="#read">
                                                            查看
                                                        </a>
                                                    </td>
                                                </tr>
                                                <</c:forEach>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

		<%--页脚 --%>
		<jsp:include page="/WEB-INF/jsps/footer.jsp"></jsp:include>
            </div>
        </div>

        <div class="page-loading-overlay">
            <div class="loader-2"></div>
        </div>

        <div class="modal fade" id="refuse">
            <div class="modal-dialog">
                <div class="modal-content">

                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">拒绝审核</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="field-1" class="control-label">审核理由</label>
                                    <input type="text" class="sr-only" value="">
                                    <textarea class="form-control" id="refuseReason" rows="3" placeholder="请输入审核理由" required="required"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-white review" data-dismiss="modal">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
         <div class="modal fade" id="check">
            <div class="modal-dialog">
                <div class="modal-content">

                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">通过审核</h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label for="field-1" class="control-label">审核理由</label>
                                     <input type="text" class="sr-only" value="">
                                    <textarea class="form-control" id="passReason" rows="3" placeholder="请输入审核理由" required="required"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-white review" data-dismiss="modal">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        
        

            <div class="modal fade" id="read">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">查看审核</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="field-1" class="control-label">邮箱</label>
                                        <input type="text" class="form-control" id="email" placeholder="user@qq.com" disabled/>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                         <label for="field-1" class="control-label">申请时间</label>
                                        <input type="text" class="form-control" id="time" placeholder="user@qq.com" disabled/>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="field-2" class="control-label">申请解冻理由</label>
                                        <textarea class="form-control" id="applicationContent" rows="3"  disabled></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="field-2" class="control-label">审核理由</label>
                                        <textarea class="form-control" id="reason" rows="3" placeholder="请输入审核理由" required="required"></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-white" data-dismiss="modal">确定</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            
        <%-- 尾部内容 --%>
        <jsp:include page="/WEB-INF/jsps/template_tail.jsp" />
        
        <!-- Imported styles on this page -->
        <link rel="stylesheet" href="assets/js/datatables/dataTables.bootstrap.css">
        <!-- Imported scripts on this page -->
        <script src="assets/js/datatables/js/jquery.dataTables.min.js"></script>
        <script src="assets/js/datatables/dataTables.bootstrap.js"></script>
        <script src="assets/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
        <!--Specific JS for this page-->
        <script type="text/javascript">
            jQuery(document).ready(function($) {
                $("#example-2").dataTable({
                    aLengthMenu: [
                        [5, 10, 25, 50, 100, -1],
                        [5, 10, 25, 50, 100, "所有"]
                    ]
                });
                // Replace checkboxes when they appear
                var $state = $("#example-2 thead input[type='checkbox']");

                $("#example-2").on('draw.dt', function() {
                    cbr_replace();

                    $state.trigger('change');
                });

                // Script to select all checkboxes
                $state.on('change', function(ev) {
                    var $chcks = $("#example-2 tbody input[type='checkbox']");

                    if($state.is(':checked')) {
                        $chcks.prop('checked', true).trigger('change');
                    } else {
                        $chcks.prop('checked', false).trigger('change');
                    }
                });
            });
        </script>
        <script type="text/javascript">
        jQuery(document).ready(function($) {

			// Delete Modal-1 
        	$('.show').on('click',function(){
        		var email = $(this).parent().prev().prev().prev().prev().text();
        		var time = $(this).parent().prev().prev().text();
        		var applicationContent = $(this).parent().prev().prev().prev().text();
        		var applicationID = $(this).parent().prev().prev().prev().prev().prev().text();
        		
        		var roleID = 4;
        		$.post(
        				"/showUserApplyThawInfo.do",
        				{
        					"email":email,
        					
        					"roleID":roleID,
        					"applicationID":applicationID
        					
        				}
        				,function(data){

        					var reason = data.datas[0].reason;
        					console.log(reason);
        					$("#email").val(email);
        					$("#time").val(time);
        					$("#applicationContent").val(applicationContent);
							$("#reason").val(reason);
        				});
        	
        		
        	});

		});
        </script>
        <script type="text/javascript">
        $(".getID").on('click',function(){
        	var applicationID = $(this).parent().prev().prev().prev().prev().prev().text();
        	$(".sr-only").val(applicationID);
       });
        
        
        jQuery(document).ready(function($) {

			// Delete Modal-1 
        	$('.review').on('click',function(){
        		var applyStatus = $(this).parent().prev().parent().prev().children().next().text();
        		var id;
        		if(applyStatus=="通过审核"){
        			applyStatus = 1;
        			id = "#passReason";
        		}else{
        			applyStatus = 0;
        			id = "#refuseReason";
        		}
        		var applicationID = $(".sr-only").val();
				var reason = $(id).val();
				console.log(applyStatus);
				console.log(applicationID);
				console.log(reason);
        		$.post(
        				"/showUserApplyThawReview.do",
        				{
        					"reason":reason,
        					"applicationID":applicationID,
        					"applyStatus":applyStatus
        					
        				}
        				,function(data){
        					 window.location.reload();
        				});
        	
        		
        	});

		});
        </script>
    </body>

</html>